<?php

namespace App\Models;

/**
 * 订单表
 */
class Order extends BaseModel
{
    protected $table = 'orders';

    /**
     * The attributes that are mass assignable.
     *
     * @var string[]
     */
    // protected $fillable = [];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array
     */
    protected $hidden = [];

    protected $guarded = [];
    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [];

    public function demands()
    {
        return $this->belongsToMany(Demand::class, 'order_object_relation', 'order_id', 'object_id')->where('type', config('project.order_object_relation.demand'));
    }
    public function services()
    {
        return $this->belongsToMany(Service::class, 'order_object_relation', 'order_id', 'object_id')->where('type', config('project.order_object_relation.service'));
    }
}
